<template>
  <div class="feedback-container">
    <!-- 动态背景装饰 -->
    <div class="bg-decorations">
      <div class="circle-1"></div>
      <div class="circle-2"></div>
      <div class="circle-3"></div>
    </div>
    
    <!-- 顶部导航（带渐变背景和装饰） -->
    <div class="top-nav">
      <div class="back-btn" @click="goBack">
        <i class="fa fa-angle-left"></i>
      </div>
      <h1 class="nav-title">反馈任务列表</h1>
      <!-- 装饰性图标 -->
      <div class="decor-icon">
        <i class="fa fa-leaf"></i>
      </div>
    </div>
    
    <!-- 顶部横幅（带微妙动画） -->
    <div class="top-banner">
      <div class="banner-content">
        <div class="banner-title">网格员任务中心</div>
        <div class="banner-subtitle">今日待处理任务</div>
        <div class="task-count">{{ aqiFeedbackArrSize }} 个</div>
      </div>
    </div>
    
    <!-- 任务列表区域（增强卡片设计） -->
    <div class="task-list-container">
      <!-- 任务列表标题栏 -->
      <div class="task-list-header">
        <h2 class="header-title">待处理任务</h2>
        <div class="header-line"></div>
      </div>
      
      <!-- 任务卡片（带渐变边框和阴影） -->
      <div 
        class="task-card" 
        v-for="aqiFeedback in aqiFeedbackArr" 
        :key="aqiFeedback.afId"
        @click="toFeedbackInfo(aqiFeedback.afId)"
      >
        <!-- 左侧信息区 -->
        <div class="task-info">
          <!-- AQI状态标签（带微妙动画） -->
          <div 
            class="aqi-tag" 
            :style="{ backgroundColor: aqiFeedback.aqi.color }"
          >
            {{ aqiFeedback.aqi.chineseExplain }}
          </div>
          <div class="text-content">
            <p class="location">
              {{ aqiFeedback.gridProvince.provinceName }} 
              {{ aqiFeedback.gridCity.cityName }} 
              <span class="date">{{ aqiFeedback.afDate }}</span>
            </p>
            <p class="address">{{ aqiFeedback.address }}</p>
          </div>
        </div>
        
        <!-- 右侧操作按钮（带动态渐变和图标动画） -->
        <div class="action-btn">
          <span>去检测</span>
          <i class="fa fa-arrow-right"></i>
        </div>
      </div>
      
      <!-- 无数据状态（带动态图标和背景） -->
      <div class="empty-state" v-if="aqiFeedbackArrSize === 0">
        <div class="empty-icon">
          <i class="fa fa-leaf"></i>
        </div>
        <p>暂无待处理的反馈任务</p>
        <p class="empty-subtext">刷新页面或返回主页</p>
      </div>
    </div>
    
    <!-- 底部装饰和版权 -->
    <div class="footer-decor">
      <div class="footer-gradient"></div>
      <div class="footer-copyright">
        © 2025 207集团股份有限公司 版权所有
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, inject } from "vue";
import { useRouter } from "vue-router";
import { getSessionStorage } from "../common.js";

const router = useRouter();
const axios = inject("axios");
const gridMember = getSessionStorage("gridMember");

const aqiFeedbackArr = ref([]);
const aqiFeedbackArrSize = ref(0);

const init = () => {
  console.log("即将发送请求，gmId = ", gridMember?.gmId);

  axios
    .post("aqiFeedback/listAqiFeedbackByGmId", {
      gmId: gridMember?.gmId,
      state: 1,
    })
    .then((response) => {
      console.log("返回数据：", response);

      const list = response?.data;
      if (Array.isArray(list)) {
        aqiFeedbackArr.value = list;
        aqiFeedbackArrSize.value = list.length;
      } else {
        console.warn("返回数据不是数组：", list);
        aqiFeedbackArr.value = [];
        aqiFeedbackArrSize.value = 0;
      }
    })
    .catch((error) => {
      console.error("请求失败：", error);
      aqiFeedbackArr.value = [];
      aqiFeedbackArrSize.value = 0;
    });
};

init();

const toFeedbackInfo = (afId) => {
  router.push({ path: "/feedbackInfo", query: { afId: afId } });
};

const goBack = () => {
  history.go(-1);
};
</script>


<style scoped>
/* ========== 全局样式 ========== */
.feedback-container {
  width: 100vw;
  min-height: 100vh;
  background: #F5FAFF; /* 浅蓝背景 */
  font-size: 4vw; /* 移动端基准字体 */
  position: relative;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* ========== 动态背景装饰 ========== */
.bg-decorations {
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;
}

.circle-1 {
  position: absolute;
  top: -100px;
  right: -100px;
  width: 200px;
  height: 200px;
  background: rgba(10, 102, 194, 0.05);
  border-radius: 50%;
  animation: float 15s ease-in-out infinite;
}

.circle-2 {
  position: absolute;
  bottom: -150px;
  left: -150px;
  width: 300px;
  height: 300px;
  background: rgba(38, 208, 206, 0.08);
  border-radius: 50%;
  animation: float 20s ease-in-out infinite;
}

.circle-3 {
  position: absolute;
  top: 30%;
  left: -50px;
  width: 100px;
  height: 100px;
  background: rgba(10, 102, 194, 0.03);
  border-radius: 50%;
  animation: float 12s ease-in-out infinite;
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(20px); }
  100% { transform: translateY(0px); }
}

/* ========== 顶部导航 ========== */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 12vw;
  background: linear-gradient(90deg, #0A66C2, #26D0CE);
  padding: 0 4vw;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 10;
  position: relative;
  overflow: hidden;
}

/* 顶部导航装饰效果 */
.top-nav::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0) 50%);
  pointer-events: none;
}

.back-btn {
  width: 8vw;
  color: #FFFFFF;
  font-size: 6vw;
  cursor: pointer;
  transition: transform 0.3s ease;
  z-index: 1;
}
.back-btn:hover {
  transform: scale(1.2);
}

.nav-title {
  flex: 1;
  text-align: center;
  font-size: 5vw;
  color: #FFFFFF;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  z-index: 1;
}

.decor-icon {
  width: 8vw;
  color: rgba(255, 255, 255, 0.6);
  font-size: 5vw;
  z-index: 1;
}

/* ========== 顶部横幅 ========== */
.top-banner {
  height: 25vw;
  background: linear-gradient(135deg, #0A66C2, #26D0CE);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

/* 横幅背景装饰 */
/* 顶部横幅背景装饰 - 修复后的SVG引用 */
/* 顶部横幅背景装饰 - 修复后的SVG引用 */


@keyframes bg-move {
  0% { background-position: 0 0; }
  100% { background-position: 100px 100px; }
}

.banner-content {
  text-align: center;
  color: #FFFFFF;
  z-index: 1;
}

.banner-title {
  font-size: 5.5vw;
  font-weight: 600;
  margin-bottom: 1vw;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.banner-subtitle {
  font-size: 4vw;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 2vw;
}

.task-count {
  font-size: 7vw;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ========== 任务列表容器（新增，优化中间区域） ========== */
.task-list-container {
  flex: 1;
  padding: 4vw;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
}

/* 任务列表标题栏 */
.task-list-header {
  display: flex;
  align-items: center;
  margin-bottom: 4vw;
}

.header-title {
  font-size: 5vw;
  font-weight: 600;
  color: #1A2980;
  margin-right: 2vw;
}

.header-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, #CADFF3, transparent);
}

/* ========== 任务卡片（增强设计） ========== */
.task-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #FFFFFF;
  border-radius: 3vw;
  padding: 4vw;
  margin-bottom: 4vw;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform: translateY(0);
  border-left: 4px solid transparent;
  border-left-color: var(--border-color, #0A66C2);
}

/* 根据AQI状态设置左侧边框颜色 */
.task-card[data-aqi="优"] {
  --border-color: #00CC66;
}
.task-card[data-aqi="良"] {
  --border-color: #FFCC33;
}
.task-card[data-aqi="轻度污染"] {
  --border-color: #FF9933;
}
.task-card[data-aqi="中度污染"] {
  --border-color: #FF6666;
}
.task-card[data-aqi="重度污染"] {
  --border-color: #CC0033;
}
.task-card[data-aqi="严重污染"] {
  --border-color: #990033;
}

/* 卡片悬停效果 */
.task-card:hover {
  box-shadow: 0 8px 20px rgba(10, 102, 194, 0.15);
  transform: translateY(-3px);
}

/* 左侧信息区 */
.task-info {
  display: flex;
  align-items: center;
  flex: 1;
}

/* AQI状态标签（带微妙动画） */
.aqi-tag {
  width: 10vw;
  height: 10vw;
  border-radius: 2vw;
  color: #FFFFFF;
  font-size: 4.5vw;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 4vw;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

.task-card:hover .aqi-tag {
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.text-content {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.location {
  font-size: 4.5vw;
  font-weight: 600;
  color: #1A2980;
  margin-bottom: 1vw;
  display: flex;
  flex-wrap: wrap;
}

.date {
  color: #606E88;
  font-weight: 400;
  margin-left: 2vw;
}

.address {
  font-size: 3.8vw;
  color: #606E88;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70vw;
}

/* 右侧操作按钮（带动态渐变和图标动画） */
.action-btn {
  display: flex;
  align-items: center;
  background: linear-gradient(135deg, #0A66C2, #26D0CE);
  color: #FFFFFF;
  padding: 2.5vw 4vw;
  border-radius: 2vw;
  font-size: 4vw;
  box-shadow: 0 3px 8px rgba(10, 102, 194, 0.2);
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform: translateX(0);
}

.action-btn:hover {
  background: linear-gradient(135deg, #0856A3, #23C0BE);
  box-shadow: 0 5px 12px rgba(10, 102, 194, 0.3);
  transform: translateX(2px);
}

.action-btn:hover i {
  animation: slide-right 0.5s ease-in-out infinite alternate;
}

@keyframes slide-right {
  0% { transform: translateX(0); }
  100% { transform: translateX(2px); }
}

.action-btn i {
  margin-left: 1vw;
  font-size: 5vw;
  transition: transform 0.3s ease;
}

/* ========== 无数据状态（带动态图标和背景） ========== */
.empty-state {
  text-align: center;
  padding: 15vw 0;
  color: #999999;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 3vw;
  margin: 4vw;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.empty-icon {
  font-size: 16vw;
  margin-bottom: 4vw;
  color: #CADFF3;
  animation: spin-slow 20s linear infinite;
}

@keyframes spin-slow {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.empty-state p {
  font-size: 4.5vw;
  margin-bottom: 1vw;
}

.empty-subtext {
  font-size: 3.5vw;
  color: #B0C4DE;
}

/* ========== 底部装饰和版权 ========== */
.footer-decor {
  position: relative;
  margin-top: 8vw;
  background: linear-gradient(to top, #0A66C2 0%, transparent 100%);
  padding-top: 5vw;
}

.footer-gradient {
  height: 10vw;
  background: linear-gradient(to top, rgba(10, 102, 194, 0.15), transparent);
}

.footer-copyright {
  text-align: center;
  padding: 3vw 0;
  font-size: 3.5vw;
  color: #606E88;
  background: #FFFFFF;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
  position: relative;
  z-index: 10;
}

/* ========== 桌面端响应式适配 ========== */
@media (min-width: 768px) {
  .feedback-container {
    font-size: 16px;
    max-width: 768px;
    margin: 0 auto;
  }

  .top-nav {
    height: 80px;
    padding: 0 30px;
  }
  .back-btn {
    font-size: 36px;
    width: 60px;
  }
  .nav-title {
    font-size: 24px;
  }
  .decor-icon {
    font-size: 28px;
    width: 60px;
  }

  .top-banner {
    height: 180px;
  }
  .banner-title {
    font-size: 32px;
    margin-bottom: 10px;
  }
  .banner-subtitle {
    font-size: 20px;
    margin-bottom: 15px;
  }
  .task-count {
    font-size: 48px;
  }

  .task-list-container {
    padding: 20px;
  }
  
  .task-list-header {
    margin-bottom: 20px;
  }
  
  .header-title {
    font-size: 24px;
    margin-right: 10px;
  }

  .task-card {
    padding: 25px;
    margin-bottom: 20px;
    border-radius: 12px;
    border-left-width: 6px;
  }
  
  .aqi-tag {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    font-size: 24px;
    margin-right: 20px;
  }
  
  .location {
    font-size: 20px;
  }
  
  .date {
    font-size: 16px;
  }
  
  .address {
    font-size: 16px;
  }
  
  .action-btn {
    padding: 12px 20px;
    font-size: 16px;
    border-radius: 8px;
  }
  
  .action-btn i {
    font-size: 20px;
    margin-left: 8px;
  }

  .empty-state {
    padding: 80px 0;
    margin: 20px;
    border-radius: 12px;
  }
  
  .empty-icon {
    font-size: 80px;
    margin-bottom: 20px;
  }
  
  .empty-state p {
    font-size: 24px;
    margin-bottom: 8px;
  }
  
  .empty-subtext {
    font-size: 18px;
  }

  .footer-decor {
    margin-top: 40px;
    padding-top: 20px;
  }
  
  .footer-gradient {
    height: 50px;
  }
  
  .footer-copyright {
    padding: 20px 0;
    font-size: 14px;
  }
}
</style>